import requests

class SendMethod:

    @staticmethod
    def send_method(method,url,params=None,data=None):
        #发送请求
        if method =='get':
            response=requests.get(url=url,params=params)
        elif method =='post':
            response=requests.post(url=url,data=data)
        else:
            response=None
            print('请求错误,请选择正确的请求方式')

        result={}
        if response is not None:
            result['status_code']=response.status_code
            result['headers']=response.headers
            result['body']=response.json()
            result['response_time']=int(response.elapsed.microseconds/1000)
            return result
        else:
            return response




